<template>
    <div v-html="scriptInfo" style="width: 100%;padding-left:25px;">

    </div>
</template>

<script>
import { viewScriptContentRequest } from '@/api/tools'
import { pageSearchPersonTaskRequest } from '@/api/user'
import { viewAnalysisScriptContentRequest } from '@/api/cloudAnalysis'
import {  pageSearchTaskRequest } from '@/api/management'
export default {
    name: 'GenecloudUiIndex',

    data() {
        return {
            queryParams: null,
            scriptInfo: '',
        };
    },
    created() {
        let obj = this.$queryToObjectsearch(window.location.search)
        if (obj.page === 'management') {
            this.init2(obj.taskName)
        } else if (obj.page === 'chartview') {
            this.queryParams = this.$queryToObjectsearch(window.location.search)
            this.init(this.queryParams)
        } else if (obj.page === 'task') {
            this.init4(obj.taskName)
        } else {
            this.queryParams = this.$queryToObjectsearch(window.location.search)
            this.init3(this.queryParams)
        }
    },
    mounted() {

    },

    methods: {
        async init(queryParams) {
            const res = await viewScriptContentRequest(queryParams)
            if (res.code !== 200) return this.$message.error(res.message)
            this.scriptInfo = res.data.replaceAll('\r', '<br>')
            this.scriptInfo = res.data.replaceAll('\n', '<br>')
        },
        async init2(keyword) {
            let query = {
                pageNo: 1,
                pageSize: 10,
                keyword
            }
            const res = await pageSearchPersonTaskRequest(query)
            if (res.code !== 200) return this.$message.error(res.message)
            let error = res.data.list[0].error
            this.scriptInfo = error.replaceAll('\r', '<br>')
            this.scriptInfo = error.replaceAll('\n', '<br>')
        },
        async init4(keyword){
            let query = {
                pageNo: 1,
                pageSize: 10,
                keyword
            }
            const res = await pageSearchTaskRequest(query)
            if (res.code !== 200) return this.$message.error(res.message)
            let error = res.data.list[0].error
            this.scriptInfo = error.replaceAll('\r', '<br>')
            this.scriptInfo = error.replaceAll('\n', '<br>')
        },
        async init3(queryParams) {
            const res = await viewAnalysisScriptContentRequest(queryParams)
            if (res.code !== 200) return this.$message.error(res.message)
            this.scriptInfo = res.data.replaceAll('\r', '<br>')
            this.scriptInfo = res.data.replaceAll('\n', '<br>')
        }
    },
};
</script>

<style lang="scss" scoped></style>